package com.atguigu.gulimall.search.controller;

import com.atguigu.gulimall.search.entity.vo.SearchParamVo;
import com.atguigu.gulimall.search.entity.vo.SearchResultVo;
import com.atguigu.gulimall.search.service.MallSearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

/**
 * @Description:
 * @Author 胡菜鸡
 * @Create 2022-01-10-9:43
 */
@Controller
public class SearchController {

    @Autowired
    MallSearchService mallSearchService;

    @GetMapping("/list.html")
    public String listPage(SearchParamVo param, Model model){
        //根据传递来的页面查询参数，去es中检索商品
        SearchResultVo result = mallSearchService.search(param);
        model.addAttribute("result", result);

        return "index";
    }

}
